import Vue from 'vue'
import axios from "axios";
import VueRouter from 'vue-router'
import App from './App.vue'
import Routes from './routes'

Vue.config.productionTip = false

Vue.use(VueRouter)

//自定义指令
Vue.directive('theme',{
  bind(el,binding){
    if(binding.value == 'wide'){
      el.style.maxWidth = '1260px';
    } else if(binding.value == 'narrow') {
      el.style.maxWidth = '560px';
    }

    if(binding.arg == 'column'){
      el.style.background = "#7f93f3";
      el.style.padding = "20px";
    }
  }
})
//自定义过滤器
Vue.filter('snippet',function(value){
  return value.slice(0,100)+"...";
})

// 创建路由
const router = new VueRouter({
  routes:Routes,
  mode:"history"
})

// 配置axios
Vue.prototype.$axios = axios;

axios.defaults.timeout = 5000;
axios.defaults.baseURL = 'http://127.0.0.1:8000/app';
axios.defaults.headers = {
  'content-type': 'application/x-www-form-urlencoded'
};

new Vue({
  render: h => h(App),
  router:router
}).$mount('#app')
